﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ContentGroup.aspx.cs" Inherits="background.Manager.Content.ContentGroup" %>

<!DOCTYPE html>
<% Hashtable ht=new Hashtable();
   ht.Add("text","文章（纯文字）");
   ht.Add("cover", "文章（带封面）"); %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>内容分组管理</title>
    <link href="../Styles/index.css" rel="stylesheet" />
    <script src="../Scripts/jquery-1.8.2.min.js"></script>
    <script src="../Scripts/layer/layer.js"></script>
    <script type="text/javascript">
        function changeOrder(obj) {
            $.post("Action/group.ashx", { action: "changeOrder", order: $(obj).val(), id: $(obj).attr("data-id") }, function (ret) {
                if (!ret) {
                    layer.msg("排序保存失败");
                }
            })
        }
        function massDelete() {
            var d = new Array();
            $("input[name='idbox']:checked").each(function () { d.push($(this).val()); })
            if (d.length == 0) { layer.msg("请选择要删除的项"); return; }

            if (confirm("确定要删除所选项吗？")) {
                $.post("Action/group.ashx", { action: "delete", idList: d.join(',') }, function (ret) {
                    if (ret) {
                        layer.msg("删除成功，2秒后自动刷新页面", { icon: 1, time: 2000 }, function () { window.location.reload(); });
                    } else {
                        layer.msg("对不起删除失败，稍后再试", { icon: 2 });
                    }
                })
            }
        }
        function deletes(id) {
            if (confirm("确定要删除吗？")) {
                $.post("Action/group.ashx", { action: "delete", idList: id }, function (ret) {
                    if (ret) {
                        layer.msg("删除成功，2秒后自动刷新页面", { icon: 1, time: 2000 }, function () { window.location.reload(); });
                    } else {
                        layer.msg("对不起删除失败，稍后再试", { icon: 2 });
                    }
                })
            }
        }
        function checkboxAll(obj) {
            $("input[name='idbox']").attr("checked", $(obj).is(":checked"));
        }
    </script>
</head>
<body>
    <div class="top">
        <strong>内容分组管理</strong>
        <span style="float: right"><a href="javascript:history.back();">
            <img src="../Images/bak.png" />后退</a></span>
    </div>
    <div class="main">
        <div>
            <div class="tool_search">
                <input type="button" class="sbtn" value="添加分组" onclick="window.location.href='addGroup.aspx?actionType=add'" />&nbsp;&nbsp;<input type="button" class="sbtn" value="批量删除" onclick="                        massDelete()" />
            </div>
            <table border="0" cellpadding="0" cellspacing="0" class="listtable">
                <tr>
                    <th class="th" style="width: 20px">
                        <input type="checkbox" onchange="checkboxAll(this)" /></th>
                        <th class="th">分组类型</th>
                    <th class="th">组名称</th>
                    <th class="th">调用拼音</th>
                    <th class="th" style="width:40px">排序</th>
                    
                    <th class="th thlast">操作</th>
                </tr>
                <%System.Data.DataTable dt= Codes.ContentGroup.getList(int.Parse(string.IsNullOrEmpty(Request["p"])?"1":Request["p"]), 20); %>
                <%foreach(System.Data.DataRow dr in dt.Rows) {%>
                <tr>
                    <td class="td">
                        <input type="checkbox" name="idbox" value="<%=dr["id"] %>" /></td>
                         <td class="td" style="width:150px"><%=ht[dr["contentType"]] %></td>
                    <td class="td"><a href="addContent.aspx?actionType=add&id=<%=dr["id"] %>"><img src="../Images/sign_add.png" style="vertical-align:middle" title="发布" /></a>&nbsp;<a style="text-decoration:underline" href="ContentList.aspx?group=<%=dr["id"] %>&title="><%=dr["title"] %></a>
                    <%=dr["state"].ToString()=="1"?"":"<sup style='color:#aaa'>(禁用)</sup>" %>
                    </td>
                    <td class="td"><%=dr["pyname"] %></td>
                    <td class="td" style="padding:0">
                        <input type="text" class="order" value="<%=dr["order"] %>" data-id="<%=dr["ID"] %>" onchange="changeOrder(this)" /></td>
                   
                    <td class="td tdlast txtcenter">
                        <a href="addGroup.aspx?actionType=update&id=<%=dr["id"] %>">
                            <img src="../Images/edit.png" class="tool_edit" />编辑</a>
                        <a href="javascript:void(0);" onclick="deletes(<%=dr["id"] %>)">
                            <img src="../Images/delete.png" class="tool_delete" />删除</a></td>
                </tr>
                <%} %>
            </table>
            <div class="tcdPageCode"></div>
            <script src="../Scripts/jquery.page.js"></script>
            <script>
                $(".tcdPageCode").createPage({
                    pageCount: '<%=Math.Ceiling((double)Codes.Links.getListCount()/20)%>',
                    current: '<%=string.IsNullOrEmpty(Request["p"])?"1":Request["p"]%>',
                    backFn: function (p) {
                        window.location.href = "?p=" + p;
                    }
                });
            </script>
        </div>
    </div>
    <!--#include file='../Include/footer.html'-->
</body>
</html>
